﻿using System;
using System.Collections.Generic;
using System.Text;
using Core.Model;
using Core.Parser.ASN1Parser.Nodes;
using Core.Exceptions;
using System.Drawing;

namespace Core.Parser.ASN1Parser.Builders
{
    internal class VisibleBuilder
    {
        internal static void Build(TaggedNode node, Visible visible, Group group)
        {
            IngredientBuilder.Build(node, visible, group);
            TaggedNode e;

            if (( e = node[ASN1ContextCodes.C_ORIGINAL_BOX_SIZE]) != null)
                visible.OriginalBoxSize = new Size(
                                                    e.First.IntValue,
                                                    e.Second.IntValue
                                                    );

            else
                throw new OpenMhegException("originalBoxSize missing");
                        
            if (( e = node[ASN1ContextCodes.C_ORIGINAL_POSITION]) != null)
                visible.OriginalBoxPosition = new Point(
                                                        e.First.IntValue,
                                                        e.Second.IntValue
                                                        );
            
            if (( e = node[ASN1ContextCodes.C_ORIGINAL_PALETTE_REF]) != null)
                throw new OpenMhegException("TODO Support OriginalPaletteRef");
        
        }
    }
}